﻿@model IList
@using (Html.BeginForm())
{
    @Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "gridView";
        DevControlHelper.InitDefaultPagerGridViewSettings(settings);
        settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
        settings.EnableAlternatingRowColor();
        settings.EnableRowIndexColumn();
        var deptcol =settings.Columns.Add("dept_name", "单位");
        deptcol.CellStyle.Wrap = DefaultBoolean.False;
        deptcol.Width = Unit.Pixel(200);
        deptcol.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add("cjdw", "承建单位").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add("cjdw_lxr", "承建单位<br>联系人").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add("cjdw_dh", "承建单位<br>联系人电话").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add("gps_num", "监控车辆数").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add("tbr", "填报人").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add("tbr_lxdh", "填报人<br>联系电话").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;

        settings.Columns.Add("tbrq", "填报日期", MVCxGridViewColumnType.DateEdit).PropertiesEdit.DisplayFormatString = "yyyy-MM-dd";
        settings.Columns.Add("note", "备注").HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        settings.Columns.Add(col =>
        {
            col.CellStyle.Paddings.Padding = 1;
            col.CellStyle.Paddings.PaddingLeft = 5;
            col.Caption = "";
            col.Width = 60;
            col.CellStyle.HorizontalAlign = HorizontalAlign.Center;

            col.SetDataItemTemplateContent(c =>
            {
                string dept_code = DataBinder.Eval(c.DataItem, "dept_code").ToString();
                ViewContext.Writer.Write(
                Html.ActionLink("[编辑]", "", null, new { href = "javascript:edit('" + dept_code + "');" })
                );
                //ViewContext.Writer.Write(Html.ActionLink("[编辑]", "GpsInstallEdit", new { id = dept_code }));
            });
        });
    }).Bind(Model).GetHtml()
}

<script type="text/javascript">
    var dept = null;
    function edit(id) {
        dept = id;
        pcModalMode.Show();
    };
    function OnBeginCallback(s, e) {
        e.customArgs["id"] = dept;
        groupId = null;
    };
    function OnEndCallback(s, e) {
    };
</script>

@Html.DevExpress().PopupControl(
settings =>
{
    settings.Name = "pcModalMode";
    settings.CallbackRouteValues = new { Controller = "Table", Action = "GpsInstallEdit"};
    settings.Width = 610;
    settings.Height = 350;
    settings.InitDefaultSettings();
    settings.HeaderText = "车辆GPS安装信息信息编辑";
}).GetHtml()
